package com.ruyuan.commodity.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruyuan.commodity.model.goods.dos.ParametersDO;
import com.ruyuan.commodity.model.goods.vo.GoodsParamsVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Parameters的Mapper
 */
@Repository
@Mapper
public interface ParametersMapper extends BaseMapper<ParametersDO> {

    /**
     * 查询分类关联的参数
     * @param categoryId 分类id
     * @return
     */
    @Results({
            @Result(column = "param_id", property = "paramId", id = true),
            @Result(column = "param_name", property = "paramName"),
            @Result(column = "param_type", property = "paramType"),
            @Result(column = "options", property = "options"),
            @Result(column = "is_index", property = "isIndex"),
            @Result(column = "required", property = "required"),
            @Result(column = "group_id", property = "groupId"),
    })
    @Select("select param_id, param_name, param_type, options, is_index, required, group_id, category_id, sort from es_parameters where category_id = #{category_id} order by sort ")
    List<GoodsParamsVO> queryParams(@Param("category_id") Long categoryId);
}
